package com.jwt.controller;

import com.jwt.pojo.Product;
import com.jwt.pojo.ResponseResult;
import com.jwt.service.ProductService;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class ProductController {
	@Resource
	ProductService productService;
	@PreAuthorize("hasAnyRole('user','manager','admin')")
	@GetMapping("/products")
	public ResponseResult<?> findAllProducts(){
		ResponseResult<List<Product>> responseResult = new ResponseResult<>();
		responseResult.setCode(200);
		responseResult.setFlag(true);
		responseResult.setMsg("查询成功");
		responseResult.setData(productService.findAllProducts());
		return responseResult;
	}
}
